var that;
var app = new Vue({
    el: "#app",
    data: {
        page: 0,
        partnerNum: 0,
        productNum: 0,
        industryNum: 0,
        isLayout: false
    },
    computed: {},
    mounted: function () {
        this.$nextTick(() => {
            window.addEventListener("scroll", this.scroll);
        });
    },
    methods: {
        sumFunc(num) {
            num = num + 10;
            if (num <= 150) {
                setTimeout(
                    () => {
                        this.partnerNum = num;
                        this.sumFunc(num);
                    },
                    num < 120 ? 50 : 200
                );
            } else {
                return;
            }
        },
        sumFunc1(num) {
            num = num + 5;
            if (num <= 100) {
                setTimeout(
                    () => {
                        this.productNum = num;
                        this.sumFunc1(num);
                    },
                    num < 80 ? 50 : 200
                );
            } else {
                return;
            }
        },
        sumFunc2(num) {
            num++;
            if (num <= 20) {
                setTimeout(
                    () => {
                        this.industryNum = num;
                        this.sumFunc2(num);
                    },
                    num < 10 ? 50 : 110
                );
            } else {
                return;
            }
        },
        scroll() {
            const wheight = window.screen.height / 2; //屏幕高
            const elOffsetTop = document.getElementById("layout_id").offsetTop; //元素距离页面顶部的距离
            const Height = document.getElementById("layout_id").offsetHeight; //元素高
            const docScrollTop = document.documentElement.scrollTop; //页面滚动的距离
            if (elOffsetTop < docScrollTop + wheight && !this.isLayout) {
                this.isLayout = true;
                this.sumFunc(0);
                this.sumFunc1(0);
                this.sumFunc2(0);
            }
        },
        // -----------------------------------------------------
        // -----------------------------------------------------
        // 监听滚动
        newIndex() {
            var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
            let h = $(".box1").height() - 70;
            if (scrollTop > h * 2) {
                this.page = 2;
                return;
            }
            this.page = Math.round(scrollTop / h);
        },
        slidMaoDian(name) {
            let scrollBox = document.body;
            let anchorElement = document.getElementsByClassName(name)[0];
            if (scrollBox) {
                window.scrollTo({
                    top: anchorElement.offsetTop, //需要滚动的距离
                    behavior: "smooth"
                });
            }
        }
    },
    destroyed() {
        window.removeEventListener("scroll", this.scroll, false);
    }
});

$(function () {});
